﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TIENITCodeGener
{
    public partial class frmCatalog : Form
    {

#region "PROPERTIES"
        private string _MAIN_CATALOG;

        public string MAIN_CATALOG
        {
            get { return _MAIN_CATALOG; }
            set { _MAIN_CATALOG = value; }
        }
        private string _SUB_CATALOG;

        public string SUB_CATALOG
        {
            get { return _SUB_CATALOG; }
            set { _SUB_CATALOG = value; }
        }
#endregion

#region "FORM EVENT"
        public frmCatalog()
        {
            InitializeComponent();
            ITFACommon.SetFormIcon(this);
            SetSkinColor();
            SetLanguage();
        }

        private void frmCatalog_Load(object sender, EventArgs e)
        {
            try
            {
                SwitchCatalog(true);
                SelectEdition();
            }
            catch
            {
            }
        }

        private void frmCatalog_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                this.Close();
            }
        }
#endregion

#region "COMMON FUNCTION"
        private void SwitchCatalog(bool isDesktop)
        {
            btn_sub_dotnet.Visible = isDesktop;
            btn_sub_java.Visible = isDesktop;
            btn_sub_windowsphone.Visible = !isDesktop;
            btn_sub_android.Visible = !isDesktop;
            btn_sub_ios.Visible = !isDesktop;
            if (isDesktop == true)
            {
                _MAIN_CATALOG = "DESKTOP";
                pn_SUB.BackColor = Color.FromArgb(0, 169, 236);
            }
            else
            {
                _MAIN_CATALOG = "DEVICES";
                pn_SUB.BackColor = Color.FromArgb(233, 119, 40);
            }
        }

        private void SelectEdition()
        {
            // EDITION
            // ULT : Ultimate - Full Option
            // PRO_NET : Professional for .NET
            // PRO_JAVA : Professional for Java
            // PRO_WP : Professional for Windows Phone
            // PRO_IOS : Professional for iOS
            // PRO_ANDROID : Professional for Android
            if (TIENITCodeGener.Properties.Settings.Default.Soft_Edition.Equals("ULT"))
            {
                lbl_Edition_Name.Text = "Ultimate";
                SwitchCatalog(true);

                btn_sub_dotnet.BackgroundImage = TIENITCodeGener.Properties.Resources.desktop_net_2;
                btn_sub_dotnet.DialogResult = DialogResult.OK;
                btn_sub_dotnet.Tag = "ON";

                btn_sub_java.BackgroundImage = TIENITCodeGener.Properties.Resources.desktop_java;
                btn_sub_java.DialogResult = DialogResult.OK;
                btn_sub_java.Tag = "ON";

                btn_sub_windowsphone.BackgroundImage = TIENITCodeGener.Properties.Resources.os_windowsphone;
                btn_sub_windowsphone.DialogResult = DialogResult.OK;
                btn_sub_windowsphone.Tag = "ON";

                btn_sub_ios.BackgroundImage = TIENITCodeGener.Properties.Resources.os_ios;
                btn_sub_ios.DialogResult = DialogResult.OK;
                btn_sub_ios.Tag = "ON";

                btn_sub_android.BackgroundImage = TIENITCodeGener.Properties.Resources.os_android;
                btn_sub_android.DialogResult = DialogResult.OK;
                btn_sub_android.Tag = "ON";
            }
            else if (TIENITCodeGener.Properties.Settings.Default.Soft_Edition.Equals("PRO_NET"))
            {
                lbl_Edition_Name.Text = "Professional for .NET";
                SwitchCatalog(true);

                btn_sub_dotnet.BackgroundImage = TIENITCodeGener.Properties.Resources.desktop_net_2;
                btn_sub_dotnet.DialogResult = DialogResult.OK;
                btn_sub_dotnet.Tag = "ON";

                btn_sub_java.BackgroundImage = TIENITCodeGener.Properties.Resources.desktop_java_dis;
                btn_sub_java.DialogResult = DialogResult.None;
                btn_sub_java.Tag = "OFF";

                btn_sub_windowsphone.BackgroundImage = TIENITCodeGener.Properties.Resources.os_windowsphone_dis;
                btn_sub_windowsphone.DialogResult = DialogResult.None;
                btn_sub_windowsphone.Tag = "OFF";

                btn_sub_ios.BackgroundImage = TIENITCodeGener.Properties.Resources.os_ios_dis;
                btn_sub_ios.DialogResult = DialogResult.None;
                btn_sub_ios.Tag = "OFF";

                btn_sub_android.BackgroundImage = TIENITCodeGener.Properties.Resources.os_android_dis;
                btn_sub_android.DialogResult = DialogResult.None;
                btn_sub_android.Tag = "OFF";
            }
            else if (TIENITCodeGener.Properties.Settings.Default.Soft_Edition.Equals("PRO_JAVA"))
            {
                lbl_Edition_Name.Text = "Professional for Java";
                SwitchCatalog(true);

                btn_sub_dotnet.BackgroundImage = TIENITCodeGener.Properties.Resources.desktop_net_2_dis;
                btn_sub_dotnet.DialogResult = DialogResult.None;
                btn_sub_dotnet.Tag = "OFF";

                btn_sub_java.BackgroundImage = TIENITCodeGener.Properties.Resources.desktop_java;
                btn_sub_java.DialogResult = DialogResult.OK;
                btn_sub_java.Tag = "ON";

                btn_sub_windowsphone.BackgroundImage = TIENITCodeGener.Properties.Resources.os_windowsphone_dis;
                btn_sub_windowsphone.DialogResult = DialogResult.None;
                btn_sub_windowsphone.Tag = "OFF";

                btn_sub_ios.BackgroundImage = TIENITCodeGener.Properties.Resources.os_ios_dis;
                btn_sub_ios.DialogResult = DialogResult.None;
                btn_sub_ios.Tag = "OFF";

                btn_sub_android.BackgroundImage = TIENITCodeGener.Properties.Resources.os_android_dis;
                btn_sub_android.DialogResult = DialogResult.None;
                btn_sub_android.Tag = "OFF";
            }
            else if (TIENITCodeGener.Properties.Settings.Default.Soft_Edition.Equals("PRO_WP"))
            {
                lbl_Edition_Name.Text = "Professional for Windows Phone";
                SwitchCatalog(false);

                btn_sub_dotnet.BackgroundImage = TIENITCodeGener.Properties.Resources.desktop_net_2_dis;
                btn_sub_dotnet.DialogResult = DialogResult.None;
                btn_sub_dotnet.Tag = "OFF";

                btn_sub_java.BackgroundImage = TIENITCodeGener.Properties.Resources.desktop_java_dis;
                btn_sub_java.DialogResult = DialogResult.None;
                btn_sub_java.Tag = "OFF";

                btn_sub_windowsphone.BackgroundImage = TIENITCodeGener.Properties.Resources.os_windowsphone;
                btn_sub_windowsphone.DialogResult = DialogResult.OK;
                btn_sub_windowsphone.Tag = "ON";

                btn_sub_ios.BackgroundImage = TIENITCodeGener.Properties.Resources.os_ios_dis;
                btn_sub_ios.DialogResult = DialogResult.None;
                btn_sub_ios.Tag = "OFF";

                btn_sub_android.BackgroundImage = TIENITCodeGener.Properties.Resources.os_android_dis;
                btn_sub_android.DialogResult = DialogResult.None;
                btn_sub_android.Tag = "OFF";
            }
            else if (TIENITCodeGener.Properties.Settings.Default.Soft_Edition.Equals("PRO_IOS"))
            {
                lbl_Edition_Name.Text = "Professional for iOS";
                SwitchCatalog(false);

                btn_sub_dotnet.BackgroundImage = TIENITCodeGener.Properties.Resources.desktop_net_2_dis;
                btn_sub_dotnet.DialogResult = DialogResult.None;
                btn_sub_dotnet.Tag = "OFF";

                btn_sub_java.BackgroundImage = TIENITCodeGener.Properties.Resources.desktop_java_dis;
                btn_sub_java.DialogResult = DialogResult.None;
                btn_sub_java.Tag = "OFF";

                btn_sub_windowsphone.BackgroundImage = TIENITCodeGener.Properties.Resources.os_windowsphone_dis;
                btn_sub_windowsphone.DialogResult = DialogResult.None;
                btn_sub_windowsphone.Tag = "OFF";

                btn_sub_ios.BackgroundImage = TIENITCodeGener.Properties.Resources.os_ios;
                btn_sub_ios.DialogResult = DialogResult.OK;
                btn_sub_ios.Tag = "ON";

                btn_sub_android.BackgroundImage = TIENITCodeGener.Properties.Resources.os_android_dis;
                btn_sub_android.DialogResult = DialogResult.None;
                btn_sub_android.Tag = "OFF";
            }
            else if (TIENITCodeGener.Properties.Settings.Default.Soft_Edition.Equals("PRO_ANDROID"))
            {
                lbl_Edition_Name.Text = "Professional for Android";
                SwitchCatalog(false);

                btn_sub_dotnet.BackgroundImage = TIENITCodeGener.Properties.Resources.desktop_net_2_dis;
                btn_sub_dotnet.DialogResult = DialogResult.None;
                btn_sub_dotnet.Tag = "OFF";

                btn_sub_java.BackgroundImage = TIENITCodeGener.Properties.Resources.desktop_java_dis;
                btn_sub_java.DialogResult = DialogResult.None;
                btn_sub_java.Tag = "OFF";

                btn_sub_windowsphone.BackgroundImage = TIENITCodeGener.Properties.Resources.os_windowsphone_dis;
                btn_sub_windowsphone.DialogResult = DialogResult.None;
                btn_sub_windowsphone.Tag = "OFF";

                btn_sub_ios.BackgroundImage = TIENITCodeGener.Properties.Resources.os_ios_dis;
                btn_sub_ios.DialogResult = DialogResult.None;
                btn_sub_ios.Tag = "OFF";

                btn_sub_android.BackgroundImage = TIENITCodeGener.Properties.Resources.os_android;
                btn_sub_android.DialogResult = DialogResult.OK;
                btn_sub_android.Tag = "ON";
            }
        }

        private void SetSkinColor()
        {
            Color colorSet = TIENITCodeGener.Properties.Settings.Default.Theme_Color;
            skinnerMetroGeneral.BackColor = colorSet;
            lbl_Edition_Name.BackColor = colorSet;
            lbl_Compatible.BackColor = colorSet;
        }

        private void SetLanguage()
        {
            if (TIENITCodeGener.Properties.Settings.Default.Soft_Language.Equals("EN-US"))
            {
                toolTipCatalog.SetToolTip(btn_mainCatalog_DESKTOP, "Code Gener For Desktop Application");
                toolTipCatalog.SetToolTip(btn_mainCatalog_DEVICES, "Code Gener For Devices Application");
                toolTipCatalog.SetToolTip(btn_sub_dotnet, "Code Gener (For .NET Desktop)");
                toolTipCatalog.SetToolTip(btn_sub_java, "Code Gener (For Java Desktop)");
                toolTipCatalog.SetToolTip(btn_sub_windowsphone, "Code Gener (For Windows Phone Devices)");
                toolTipCatalog.SetToolTip(btn_sub_android, "Code Gener (For Android Devices)");
                toolTipCatalog.SetToolTip(btn_sub_ios, "Code Gener (For iOS Devices)");
                lbl_Compatible.Text = "Compatible with";
                toolTipCatalog.SetToolTip(btn_compatible_8, "Compatible with Windows 8");
                toolTipCatalog.SetToolTip(btn_compatible_7, "Compatible with Windows 7");
                toolTipCatalog.SetToolTip(btn_compatible_xp, "Compatible with Windows XP");
            }
            else if (TIENITCodeGener.Properties.Settings.Default.Soft_Language.Equals("VI-VN"))
            {
                toolTipCatalog.SetToolTip(btn_mainCatalog_DESKTOP, "Hỗ trợ xây dựng ứng dụng để bàn");
                toolTipCatalog.SetToolTip(btn_mainCatalog_DEVICES, "Hỗ trợ xây dựng ứng dụng thiết bị cầm tay");
                toolTipCatalog.SetToolTip(btn_sub_dotnet, "Phiên bản hỗ trợ xây dựng ứng dụng .NET");
                toolTipCatalog.SetToolTip(btn_sub_java, "Phiên bản hỗ trợ xây dựng ứng dụng  Java");
                toolTipCatalog.SetToolTip(btn_sub_windowsphone, "Phiên bản hỗ trợ xây dựng ứng dụng Windows Phone");
                toolTipCatalog.SetToolTip(btn_sub_android, "Phiên bản hỗ trợ xây dựng ứng dụng Android");
                toolTipCatalog.SetToolTip(btn_sub_ios, "Phiên bản hỗ trợ xây dựng ứng dụng iOS");
                lbl_Compatible.Text = "Tương thích với";
                toolTipCatalog.SetToolTip(btn_compatible_8, "Tương thích với Windows 8");
                toolTipCatalog.SetToolTip(btn_compatible_7, "Tương thích với Windows 7");
                toolTipCatalog.SetToolTip(btn_compatible_xp, "Tương thích với Windows XP");
            }
        }
#endregion

#region "MAIN CATALOG"
        private void btn_mainCatalog_DESKTOP_Click(object sender, EventArgs e)
        {
            SwitchCatalog(true);
        }

        private void btn_mainCatalog_DESKTOP_MouseLeave(object sender, EventArgs e)
        {
            btn_mainCatalog_DESKTOP.FlatAppearance.BorderSize = 0;
        }

        private void btn_mainCatalog_DESKTOP_MouseMove(object sender, MouseEventArgs e)
        {
            btn_mainCatalog_DESKTOP.FlatAppearance.BorderSize = 1;
        }

        private void btn_mainCatalog_DEVICES_Click(object sender, EventArgs e)
        {
            SwitchCatalog(false);
        }

        private void btn_mainCatalog_DEVICES_MouseLeave(object sender, EventArgs e)
        {
            btn_mainCatalog_DEVICES.FlatAppearance.BorderSize = 0;
        }

        private void btn_mainCatalog_DEVICES_MouseMove(object sender, MouseEventArgs e)
        {
            btn_mainCatalog_DEVICES.FlatAppearance.BorderSize = 1;
        }
#endregion

#region "SUB CATALOG"
        private void btn_sub_windowsphone_Click(object sender, EventArgs e)
        {
            _SUB_CATALOG = "WINDOWS_PHONE";
        }

        private void btn_sub_windowsphone_MouseLeave(object sender, EventArgs e)
        {
            btn_sub_windowsphone.FlatAppearance.BorderSize = 0;
            if (btn_sub_windowsphone.Tag.ToString().Equals("OFF"))
            {
                btn_sub_windowsphone.BackgroundImage = TIENITCodeGener.Properties.Resources.os_windowsphone_dis;
            }
        }

        private void btn_sub_windowsphone_MouseMove(object sender, MouseEventArgs e)
        {
            btn_sub_windowsphone.FlatAppearance.BorderSize = 1;
            btn_sub_windowsphone.BackgroundImage = TIENITCodeGener.Properties.Resources.os_windowsphone;
        }

        private void btn_sub_dotnet_Click(object sender, EventArgs e)
        {
            _SUB_CATALOG = "DOTNET";
        }

        private void btn_sub_dotnet_MouseLeave(object sender, EventArgs e)
        {
            btn_sub_dotnet.FlatAppearance.BorderSize = 0;
            if (btn_sub_dotnet.Tag.ToString().Equals("OFF"))
            {
                btn_sub_dotnet.BackgroundImage = TIENITCodeGener.Properties.Resources.desktop_net_2_dis;
            }
        }

        private void btn_sub_dotnet_MouseMove(object sender, MouseEventArgs e)
        {
            btn_sub_dotnet.FlatAppearance.BorderSize = 1;
            btn_sub_dotnet.BackgroundImage = TIENITCodeGener.Properties.Resources.desktop_net_2;
        }

        private void btn_sub_android_Click(object sender, EventArgs e)
        {
            _SUB_CATALOG = "ANDROID";
        }

        private void btn_sub_android_MouseMove(object sender, MouseEventArgs e)
        {
            btn_sub_android.FlatAppearance.BorderSize = 1;
            btn_sub_android.BackgroundImage = TIENITCodeGener.Properties.Resources.os_android;
        }

        private void btn_sub_android_MouseLeave(object sender, EventArgs e)
        {
            btn_sub_android.FlatAppearance.BorderSize = 0;
            if (btn_sub_android.Tag.ToString().Equals("OFF"))
            {
                btn_sub_android.BackgroundImage = TIENITCodeGener.Properties.Resources.os_android_dis;
            }
        }

        private void btn_sub_java_Click(object sender, EventArgs e)
        {
            _SUB_CATALOG = "JAVA";
        }

        private void btn_sub_java_MouseLeave(object sender, EventArgs e)
        {
            btn_sub_java.FlatAppearance.BorderSize = 0;
            if (btn_sub_java.Tag.ToString().Equals("OFF"))
            {
                btn_sub_java.BackgroundImage = TIENITCodeGener.Properties.Resources.desktop_java_dis;
            }
        }

        private void btn_sub_java_MouseMove(object sender, MouseEventArgs e)
        {
            btn_sub_java.FlatAppearance.BorderSize = 1;
            btn_sub_java.BackgroundImage = TIENITCodeGener.Properties.Resources.desktop_java;
        }

        private void btn_sub_ios_Click(object sender, EventArgs e)
        {
            _SUB_CATALOG = "IOS";
        }

        private void btn_sub_ios_MouseLeave(object sender, EventArgs e)
        {
            btn_sub_ios.FlatAppearance.BorderSize = 0;
            if (btn_sub_ios.Tag.ToString().Equals("OFF"))
            {
                btn_sub_ios.BackgroundImage = TIENITCodeGener.Properties.Resources.os_ios_dis;
            }
        }

        private void btn_sub_ios_MouseMove(object sender, MouseEventArgs e)
        {
            btn_sub_ios.FlatAppearance.BorderSize = 1;
            btn_sub_ios.BackgroundImage = TIENITCodeGener.Properties.Resources.os_ios;
        }
#endregion

    }
}
